<?php

  class SuserAction extends CommonAction{
  
     public function index(){
	
	  if(isset($_GET['keywords'])){
	  
	    $this->keyword=$_GET['keywords'];
		
		$keyword=$_GET['keywords'];
		
		$where['username']=array("LIKE","%$keyword%");
	  
	  }
	
      
	  $re=$this->page('suser','10','id desc',$where);
      	
	  $this->re=$re;	
		
	  $this->display();
	
	}
  
    public function add(){
	
	  if(!empty($_POST)){

        if($_POST['password']==$_POST['repass']){
	   
	      $arr['password']=md5($_POST['password']);
	      $arr['username']=$_POST['username'];
	      $re=M('suser')->add($arr);
		  
		  if($re){
		    
			$this->success('添加上传用户成功');exit();
		  
		  }else{
		  
		    $this->error('添加失败');
		  
		  }
		  
	    }else{
		
		  $this->error('两次密码输入不一致');
		
		}
	    
	  }
	
	  $this->display();
	}
  
  
    public function del(){
	
	  $this->ajaxReturn((M('suser')->where('id="%s"',$_POST['id'])->delete())?1:2);
	
	}
  
  
  }